package com.lk.controller;

import com.lk.service.MyService;
import com.lk.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.retry.annotation.Retryable;
import org.springframework.retry.support.RetryTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @author : lk
 * @date 2021/11/18 14:11
 * @description : 异常重试demo
 * @since 1.0
 **/
@RestController
@Retryable()
public class HelloController {

    private MyService myService;
    @Resource
    private UserService userService;

    @Autowired
    private RetryTemplate retryTemplate;

    public HelloController(MyService myService) {
        this.myService = myService;
    }

    @GetMapping("hello")
    public String hello() {
        return myService.retryService("重试的sql");
    }

}
